package com.xzx.mr.index;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @author xinzhixuan
 * @version V1.0
 * @date 2019/8/9 21:42
 */
public class OneIndexReducer extends Reducer<Text, IntWritable, Text, IntWritable> {
    private IntWritable v = new IntWritable();

    @Override
    protected void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException,
            InterruptedException {
        int sum = 0;
        for (IntWritable value : values) {
            sum += 1;
        }
        v.set(sum);
        context.write(key, v);
    }
}
